import React, { useState, useEffect } from "react";

import { ratedApi } from "@/api/api";

const Index = () => {
  const [list, setList] = useState([]);

  // 如果要在useEffect里面去使用async，那么需要写成自执行函数
  // useEffect(async () => {
  //   const res = await ratedApi();
  //   setList(res.result);
  // }, []);

  useEffect(() => {
    (async () => {
      const res = await ratedApi({ a: 3, b: 4 });
      setList(res.result);
    })();
  }, []);

  // useEffect(() => {
  //   Promise.all([ratedApi(), listApi()]).then(res => {

  //   })
  // }, [])

  return (
    <>
      <div>这是电影影院页面</div>
      <ul>
        {list.map((item) => (
          <li key={item._id}>{item.title}</li>
        ))}
      </ul>
    </>
  );
};

export default Index;
